﻿namespace Json2Model
{
    public class JAttribute
    {
        /// <summary>
        /// 属性名
        /// </summary>
        public string Name { get; set; } = string.Empty;
        /// <summary>
        /// 属性的类型名
        /// </summary>
        public string TypeName { get; set; } = string.Empty;

        public override bool Equals(object? j)
        {
            if (!(j is JAttribute))
                return false;
            JAttribute attribute = (JAttribute)j; 
            return (this.Name == attribute.Name && this.TypeName == attribute.TypeName);
        }

        public override int GetHashCode()
        {
            return (this.Name + "|" + this.TypeName).GetHashCode();
        }

        public static bool operator ==(JAttribute l, JAttribute r)
        {
            return l.Name == r.Name && l.TypeName == r.TypeName;
        }
        public static bool operator !=(JAttribute l, JAttribute r)
        {
            return !(l == r);
        }
    }
}
